package com.example.administrator.myapplication.Presenter;

import android.content.Context;

import com.example.administrator.myapplication.Bean.AjaxResult;
import com.example.administrator.myapplication.Model.ILoginModel;
import com.example.administrator.myapplication.Model.LoginModel;
import com.example.administrator.myapplication.View.Activity.ILoginView;
import com.example.administrator.myapplication.View.Fragment.IInfoView;

import java.io.IOException;

import okhttp3.ResponseBody;

/**
 * Created by Administrator on 2019/6/14 0014.
 */

public class LoginPresenter implements ILoginPresenter,ILoginListener{
    private ILoginView iLoginView;
    private ILoginModel iLoginModel;
    public LoginPresenter(ILoginView loginView){
        this.iLoginView = loginView;
        this.iLoginModel = new LoginModel();
    }

    @Override
    public void success(AjaxResult json){
        if(json.getCode()==AjaxResult.SUCCESS_CODE)
            iLoginView.showSuccess(json.getMsg());
        else
            iLoginView.showError(json.getMsg());
    }

    @Override
    public void fail(String error) {
        iLoginView.showError(error);
    }

    @Override
    public void login(String username,String password,String validateCode,boolean rememberMe) {
        iLoginModel.login(username,password,rememberMe,validateCode,this);
    }

}
